class ParamsTypeError(Exception):
    def __init__(self, error_info):
        super().__init__(self)
        self.error_info = error_info

    def __str__(self):
        return self.error_info


def fibonacci_for(num):
    try:
        num = int(num)
        a, b = 0, 1
        results = [a, b]
        if num == 0:
            return [a]
        elif num == 1:
            return [a, b]
        for i in range(num - 1):
            a = a + b
            b, a = a, b
            results.append(b)
        return results
    except Exception as e:
        raise ParamsTypeError("参数类型错误 应为int 或者整数str")


def fibonacci_while(num):
    try:
        num = int(num)
        a, b = 0, 1
        results = [a, b]
        if num == 0:
            return [a]
        elif num == 1:
            return [a, b]
        i = 0
        while i < num - 1:
            b, a = a + b, b
            results.append(b)
            i += 1
        return results
    except Exception as e:
        raise ParamsTypeError("参数类型错误 应为int 或者整数str")


if __name__ == '__main__':
    print(fibonacci_for('10'))
    print(fibonacci_while('10'))
